//
//  QMATritonSDKDelegateImp.m
//  QQMiniGameSDKDemo
//
//  Created by Goyoungs on 2023/4/14.
//

#import "QMATritonSDKDelegateImp.h"
#import <QQMiniGameLogin/QQMiniGameLogin.h>
OBJC_EXTERN NSString *const DemoErrorHeartBeatSwitch;

@implementation QMATritonSDKDelegateImp

#pragma mark - 小游戏 triton delegate

/// 默认Release ，debug环境可开启TTCurrentDebugState_Debug
- (TTCurrentDebugState)currentDebugState {
#ifdef DEBUG
    return TTCurrentDebugState_Debug;
#endif
    return TTCurrentDebugState_Release;
}

#pragma mark - 防沉迷

- (BOOL)enableHeartBeart {
    //TODO: 宿主如果有自己的防沉迷机制，可以关闭
//    NSNumber *tipSwitch = [[NSUserDefaults standardUserDefaults] objectForKey:DemoErrorHeartBeatSwitch];
//    if(tipSwitch && [tipSwitch isKindOfClass:[NSNumber class]]) {
//        return [tipSwitch boolValue];
//    }
    return NO;
}

- (void)needLoginAction:(void (^)(BOOL))complete parentVC:(nonnull UIViewController *)parentVC {
    //防沉迷需要登录
    [[QQMiniGameLoginManager sharedInstance] login:parentVC complete:^(NSError * _Nullable error, QQMiniGameLoginType type) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if(complete) {
                complete(error ? NO : YES);
            }
        });
    }];
}
   


@end
